package com.justech.mes.utils;

import java.util.Collection;
import java.util.HashSet;
import java.util.Set;

/**
 * @author feifei.li
 */
public class CollectionUtils {

    /**
     * 判断集合是否为空
     *
     * @param collection
     * @return
     */
    public static boolean notEmpty(Collection collection) {
        return collection != null && collection.size() > 0;
    }

    /**
     * 判断集合中是否有元素
     *
     * @param collection
     * @return
     */
    public static boolean has(Collection collection) {
        return collection != null && collection.size() > 0;
    }

    /**
     * 没有东西存在
     *
     * @param collection
     * @return
     */
    public static boolean nothing(Collection collection) {
        return !has(collection);
    }

    public static <T> Set<T> add(T object) {
        Set<T> arrayList = new HashSet<>();
        arrayList.add(object);
        return arrayList;
    }
}
